package com.studio701.carguard.controller;


import com.studio701.carguard.pojo.HumanBody;
import com.studio701.carguard.pojo.RespBean;
import com.studio701.carguard.service.IHumanBodyService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author xjc
 * @since 2022-03-16
 */
@RestController
@RequestMapping("/human-body")
public class HumanBodyController {

    @Autowired
    IHumanBodyService humanBodyService;

    @ApiOperation("添加人体信息")
    @PostMapping("/")
    public boolean insertHumanBody(@RequestBody HumanBody HumanBody){
        return humanBodyService.save(HumanBody);
    }

    @ApiOperation("修改人体信息")
    @PutMapping("/")
    RespBean updateHumanBody(@RequestBody HumanBody humanBody){
        if (humanBodyService.updateById(humanBody)){
            return RespBean.success("更新成功");
        }else {
            return RespBean.error("更新失败");
        }
    }

    @ApiOperation("获得人体信息")
    @GetMapping("/")
    HumanBody getById(Integer id){
        return humanBodyService.getById(id);
    }
}
